home *** CD-ROM | disk | FTP | other *** search
/ Double Doozy / Double Doozy - Accessories with Attitude (USA).7z / track.bin / doozy.mst < prev    next >
Text File  |  1994-10-23  |  11KB  |  421 lines

  1. '' ---------------------------------------------------------------------
  2. ''
  3. ''                    Double Doozy Setup
  4. ''
  5. '' ---------------------------------------------------------------------
  6.  
  7. '' '$define DEBUG  ''Define for script development/debugging
  8.  
  9. '' ---------------------------------------------------------------------
  10.  
  11. '$include 'setupapi.inc'
  12. '$include 'msdetect.inc'
  13.  
  14. '' ---------------------------------------------------------------------
  15.  
  16. '' Resource ID's
  17. CONST IDICN_SETUP       = 6000
  18. CONST IDBMP_LOGO        = 6100
  19.  
  20. '' Custom Dialog IDs
  21. CONST IDDLG_WELCOME       = 100
  22. CONST IDDLG_ASKQUIT       = 200
  23. CONST IDDLG_DESTPATH      = 300
  24. CONST IDDLG_EXITQUIT      = 400
  25. CONST IDDLG_EXITSUCCESS   = 500
  26. CONST IDDLG_NODISKSPACE   = 600
  27. CONST IDDLG_SELECTOPTIONS = 700
  28.  
  29. '' Custom user interface dll
  30. CONST CUIDLL$ = "cui.dll"
  31.  
  32. '' ---------------------------------------------------------------------
  33.  
  34. '' Default destination directory.
  35. GLOBAL DEST$
  36.  
  37. '' Options
  38. GLOBAL OptScreenSavers%
  39. GLOBAL OptWallPapers%
  40. GLOBAL OptIcons%
  41.  
  42. '' Section names, case sensitive: any files without a section go under "Files"
  43. CONST ProgramKey$    = "doozy"
  44. CONST WallPaperKey$  = "wallpaper"
  45. CONST IconKey$       = "icon"
  46. CONST FontKey$       = "font"
  47.  
  48. '' ---------------------------------------------------------------------
  49.  
  50. '' Font installation functions
  51. DECLARE FUNCTION CreateScalableFontResource LIB "gdi" (fHidden%, szDestFontName$, szFontFile$, szFontFilePath$) AS INTEGER
  52. DECLARE FUNCTION AddFontResource LIB "gdi" (szDestFontName$) AS INTEGER
  53. DECLARE FUNCTION SendMessage LIB "user" (hwnd%, uMsg%, wParam%, lParam&) AS LONG
  54.  
  55. CONST HWND_BROADCAST = 65535    '' 0xffff
  56. CONST WM_FONTCHANGE  = 29       '' 0x001D
  57.  
  58. '' My DLL functions
  59. DECLARE FUNCTION CountSectionSizes LIB "cui.dll" (section$, keylistname$) AS LONG
  60. DECLARE FUNCTION IsStringInFile LIB "cui.dll" (lpszFilename$, lpszString$) AS INTEGER
  61.  
  62. '' Local function declarations
  63. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  64. DECLARE SUB BuildCopyList
  65. DECLARE SUB Install
  66. DECLARE SUB AskQuit
  67. DECLARE SUB AddGroupItem (szGroup$, szTitle$, ProgName$)
  68.  
  69. '' ---------------------------------------------------------------------
  70.  
  71. '' Lets do an installation ...
  72. INIT:
  73.     ON ERROR GOTO QUIT
  74.  
  75.     '' Some standard setup stuff
  76.     SetBitmap CUIDLL$, IDBMP_LOGO
  77.     SetTitle "Double Doozy Setup"
  78.  
  79.     '' Make a complete path to the INF file
  80.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  81.     IF szInf$ = "" THEN
  82.        szInf$ = GetSymbolValue("STF_CWDDIR") + "DOOZY.INF"
  83.     END IF
  84.  
  85.     '' Read in the INF file
  86.     ReadInfFile szInf$
  87.  
  88.     '' Screen savers go in the windows directory
  89.     DEST$ = GetWindowsDir()
  90.  
  91.     '' Default: select all options
  92.     OptScreenSavers% = 1
  93.     OptWallPapers% = 1
  94.     OptIcons% = 1
  95.  
  96.     ''FOR i% = 1 TO 3 STEP 1
  97.     ''    AddListItem CHECKSTATES$, "ON"
  98.     ''NEXT i%
  99.  
  100. '$ifdef DEBUG
  101.     i% = SetSizeCheckMode(scmOnIgnore)
  102. '$else
  103.     i% = SetSizeCheckMode(scmOnFatal)
  104. '$endif
  105.  
  106.  
  107. WELCOME:
  108.     sz$ = UIStartDlg(CUIDLL$, IDDLG_WELCOME, "FDlgProc", 0, "")
  109.     IF sz$ = "CONTINUE" THEN
  110.         UIPop 1
  111.     ELSEIF sz$ = "REACTIVATE" THEN
  112.         GOTO WELCOME
  113.     ELSE
  114.         ASKQUIT
  115.         GOTO WELCOME
  116.     END IF
  117.  
  118.  
  119. SELECTOPTIONS:
  120.     '' Space needed
  121.     Bytes& = CountSectionSizes&(ProgramKey$, "") + CountSectionSizes&(FontKey$, "")
  122.     SetSymbolValue "Text1", STR$(Bytes& / 1024) + "K"
  123.  
  124.     Bytes& = CountSectionSizes&(WallPaperKey$, "")
  125.     SetSymbolValue "Text2", STR$(Bytes& / 1024) + "K"
  126.  
  127.     Bytes& = CountSectionSizes&(IconKey$, "")
  128.     SetSymbolValue "Text3", STR$(Bytes& / 1024) + "K"
  129.  
  130.     '' Check the options
  131.     SetSymbolValue "CheckItemsIn", ""
  132.     IF OptScreenSavers% = 1 THEN
  133.         AddListItem "CheckItemsIn", "ON"
  134.     ELSE
  135.         AddListItem "CheckItemsIn", "OFF"
  136.     END IF
  137.  
  138.     IF OptWallPapers% = 1 THEN
  139.         AddListItem "CheckItemsIn", "ON"
  140.     ELSE
  141.         AddListItem "CheckItemsIn", "OFF"
  142.     END IF
  143.  
  144.     IF OptIcons% = 1 THEN
  145.         AddListItem "CheckItemsIn", "ON"
  146.     ELSE
  147.         AddListItem "CheckItemsIn", "OFF"
  148.     END IF
  149.  
  150. SELECTOPTIONS1:
  151.     '' Run the dialog
  152.     sz$ = UIStartDlg(CUIDLL$, IDDLG_SELECTOPTIONS, "FDlgProc", 0, "")
  153.     IF sz$ = "CONTINUE" OR sz$ = "BACK" THEN
  154.  
  155.         '' Retrieve the options
  156.         IF GetListItem("CheckItemsOut", 1) = "ON" THEN
  157.             OptScreenSavers% = 1
  158.         ELSE
  159.             OptScreenSavers% = 0
  160.         END IF
  161.  
  162.         IF GetListItem("CheckItemsOut", 2) = "ON" THEN
  163.             OptWallPapers% = 1
  164.         ELSE
  165.             OptWallPapers% = 0
  166.         END IF
  167.  
  168.         IF GetListItem("CheckItemsOut", 3) = "ON" THEN
  169.             OptIcons% = 1
  170.         ELSE
  171.             OptIcons% = 0
  172.         END IF
  173.  
  174.         UIPop 1
  175.  
  176.         IF sz$ = "BACK" THEN
  177.             GOTO WELCOME
  178.         END IF
  179.  
  180.     ELSEIF sz$ = "REACTIVATE" THEN
  181.         GOTO SELECTOPTIONS1
  182.     ELSE
  183.         ASKQUIT
  184.         GOTO SELECTOPTIONS
  185.     END IF
  186.  
  187.     '' Like it says
  188.     BuildCopyList
  189.  
  190. RECALC:
  191.     '' Check the amount of space needed
  192.     StillNeed& = GetCopyListCost("ExtraCostsList", "CostCostsList", "NeededCostsList")
  193.     IF StillNeed& <> 0 THEN
  194. SPACE_CHECK_DLG:
  195.         '' Space required
  196.         SetSymbolValue "Text1", STR$(StillNeed& / 1024) + "K"
  197.  
  198.         '' Space available
  199.         Bytes& = GetFreeSpaceForDrive(Mid$(DEST$, 1, 1))
  200.         SetSymbolValue "Text2", STR$(Bytes& / 1024) + "K"
  201.  
  202. SPACE_CHECK_DLG1:
  203.         sz$ = UIStartDlg(CUIDLL$, IDDLG_NODISKSPACE, "FDlgProc", 0, "")
  204.         IF sz$ = "CONTINUE" THEN
  205.             UIPop 1
  206.             GOTO SELECTOPTIONS
  207.         ELSEIF sz$ = "REACTIVATE" THEN
  208.             GOTO RECALC
  209.         ELSE
  210.             ASKQUIT
  211.             GOTO SPACE_CHECK_DLG
  212.         END IF
  213.     ENDIF
  214.  
  215.     '' Perform the installation
  216.     Install
  217.  
  218.  
  219. QUIT:
  220.     IF ERR = 0 THEN
  221.         dlg% = IDDLG_EXITSUCCESS
  222.     ELSEIF ERR = STFQUIT THEN
  223.         dlg% = IDDLG_EXITQUIT
  224.     ELSE
  225.         dlg% = IDDLG_EXITQUIT
  226.     END IF
  227.  
  228. QUITL1:
  229.     SetSymbolValue "Text1", ""
  230.     SetSymbolValue "Text2", ""
  231.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FDlgProc", 0, "")
  232.     IF sz$ = "REACTIVATE" THEN
  233.         GOTO QUITL1
  234.     END IF
  235.     UIPop 1
  236.  
  237.     END
  238.  
  239. '' ---------------------------------------------------------------------
  240.  
  241. SUB BuildCopyList STATIC
  242.  
  243.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  244.  
  245.     ClearCopyList
  246.  
  247.     IF OptScreenSavers% = 1 THEN
  248.  
  249.         '' Add all screen savers
  250.         AddSectionFilesToCopyList ProgramKey$, SrcDir$, DEST$
  251.  
  252.         '' Install the font only if NOT there ...
  253.         '' The font should be in the system directory.
  254.         szDestFontName$ = MakePath$(GetWindowsSysDir, "doozy.fot")
  255.         IF DoesFileExist(szDestFontName$, femExists) = 0 THEN
  256.             AddSectionFilesToCopyList FontKey$, SrcDir$, GetWindowsSysDir
  257.         END IF
  258.  
  259.     END IF
  260.  
  261.     IF OptWallPapers% = 1 THEN
  262.         AddSectionFilesToCopyList WallPaperKey$, SrcDir$, DEST$
  263.     END IF
  264.  
  265.     IF OptIcons% = 1 THEN
  266.         AddSectionFilesToCopyList IconKey$, SrcDir$, DEST$
  267.     END IF
  268.  
  269. END SUB
  270.  
  271. '' ---------------------------------------------------------------------
  272. '**
  273. '** Purpose:
  274. '**     Builds the copy list and performs all installation operations.
  275. '** Arguments:
  276. '**     none.
  277. '** Returns:
  278. '**     none.
  279. '*************************************************************************
  280.  
  281. SUB Install STATIC
  282.  
  283.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  284.     CreateDir DEST$, cmoNone
  285.  
  286.     ClearBillboardList
  287.     CopyFilesInCopyList
  288.  
  289.     hCursor% = ShowWaitCursor()
  290.  
  291.     IF OptScreenSavers% = 1 THEN
  292.  
  293.         '' The font will be in the system directory at this point.
  294.         szDestFontName$ = MakePath$(GetWindowsSysDir, "doozy.fot")
  295.  
  296.         '' Install the font
  297.         i% = CreateScalableFontResource(0, szDestFontName$, "doozy.ttf", GetWindowsSysDir)
  298. '$ifdef DEBUG
  299.         if i% = 0 THEN
  300.             i% = DoMsgBox("Error creating the font " + szDestFontName$ + ".", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  301.         end if
  302. '$endif DEBUG
  303.  
  304.         i% = AddFontResource(szDestFontName$)
  305. '$ifdef DEBUG
  306.         if i% = 0 THEN
  307.             i% = DoMsgBox("Error adding the font " + szDestFontName$, "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  308.         end if
  309. '$endif DEBUG
  310.         lRet& = SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0)
  311.  
  312.  
  313.         '' Create a video toys group
  314.         grp$ = "Video Toys"
  315.         CreateProgmanGroup grp$, "", cmoNone
  316.  
  317.         '' Place the order form file in the group window
  318.         IF IsStringInFile(MakePath$(DEST$, "videotoy.grp"), "orderfrm.wri") = 0 THEN
  319.             CreateProgmanItem grp$, "Order Form", "write.exe " + MakePath$(DEST$, "orderfrm.wri"), "", cmoOverwrite
  320.         END IF
  321.  
  322.         '' Add all the screen savers to the group (Alphabetized)
  323.         AddGroupItem grp$, "Aerobics", "aerobics.scr"
  324.         AddGroupItem grp$, "Artist", "artist.scr"
  325.         AddGroupItem grp$, "Children's Story", "kids.scr"
  326.         AddGroupItem grp$, "Deadhead", "deadhead.scr"
  327.         AddGroupItem grp$, "Graffiti", "graffiti.scr"
  328.         AddGroupItem grp$, "Greyhound", "gryhound.scr"
  329.         AddGroupItem grp$, "Hen", "hen.scr"
  330.         AddGroupItem grp$, "Magician", "magician.scr"
  331.         AddGroupItem grp$, "Oops!", "crash.scr"
  332.         AddGroupItem grp$, "Paranoid", "paranoid.scr"
  333.         AddGroupItem grp$, "Pig", "pig.scr"
  334.         AddGroupItem grp$, "Poet", "poetry.scr"
  335.         AddGroupItem grp$, "Rock 'n' Roller", "rocker.scr"
  336.         AddGroupItem grp$, "Shocked", "shocked.scr"
  337.         AddGroupItem grp$, "Skateboarder", "skatebrd.scr"
  338.         AddGroupItem grp$, "Snails", "snails.scr"
  339.         AddGroupItem grp$, "Streaker", "streaker.scr"
  340.         AddGroupItem grp$, "Teeth Cleaner", "teeth.scr"
  341.         AddGroupItem grp$, "Telephone Talker", "chat.scr"
  342.         AddGroupItem grp$, "Yes-Man", "yesman.scr"
  343.  
  344.         '' Display the group window
  345.         ShowProgmanGroup grp$, 1, cmoNone
  346.  
  347.     END IF
  348.  
  349.     RestoreCursor hCursor%
  350.  
  351. END SUB
  352.  
  353. '*************************************************************************
  354.  
  355. '**
  356. '** Purpose:
  357. '**     Appends a file name to the end of a directory path,
  358. '**     inserting a backslash character as needed.
  359. '** Arguments:
  360. '**     szDir$  - full directory path (with optional ending "\")
  361. '**     szFile$ - filename to append to directory
  362. '** Returns:
  363. '**     Resulting fully qualified path name.
  364. '*************************************************************************
  365.  
  366. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  367.  
  368.     IF szDir$ = "" THEN
  369.         MakePath = szFile$
  370.     ELSEIF szFile$ = "" THEN
  371.         MakePath = szDir$
  372.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  373.         MakePath = szDir$ + szFile$
  374.     ELSE
  375.         MakePath = szDir$ + "\" + szFile$
  376.     END IF
  377.  
  378. END FUNCTION
  379.  
  380. '' ---------------------------------------------------------------------
  381.  
  382. '**
  383. '** Ask the user if they want to quit.
  384. '**
  385.  
  386. SUB AskQuit STATIC
  387.  
  388. _ASKQUIT:
  389.     sz$ = UIStartDlg(CUIDLL$, IDDLG_ASKQUIT, "FDlgProc", 0, "")
  390.  
  391.     IF sz$ = "EXIT" THEN
  392.         UIPopAll
  393.         ERROR STFQUIT
  394.     ELSEIF sz$ = "REACTIVATE" THEN
  395.         GOTO _ASKQUIT
  396.     ELSE
  397.         UIPop 1
  398.     END IF
  399.  
  400. END SUB
  401.  
  402. '' ---------------------------------------------------------------------
  403.  
  404. '**
  405. '** Add the given item to the video toys group if the item is
  406. '** not there yet.
  407. '**
  408. '** Pass the items title and the screen savers disk file name.
  409. '**
  410.  
  411. SUB AddGroupItem (szGroup$, szTitle$, ProgName$) STATIC
  412.  
  413.     IF IsStringInFile(MakePath$(DEST$, "videotoy.grp"), ProgName$) = 0 THEN
  414.         runscr$ = MakePath$(DEST$, "runscr.exe")
  415.         CreateProgmanItem szGroup$, szTitle$, runscr$ + " " + ProgName$ + " /s", ProgName$ + ",,,,", cmoOverwrite
  416.     END IF
  417.  
  418. END SUB
  419.  
  420. '' ---------------------------------------------------------------------
  421.